package com.itany.corejava.day07;

public class Test3 {

    public static void main(String[] args) {

        /*
            1.分配父类空间
            2.分配子类空间
            3.初始化
            4.调用构造方法,构造方法第一行是super()调用父类构造方法
         */
        // Bird bird=new Bird();

        Animal bird=new Bird();
        // Object bird=new Bird();
        bird.setName("b1");
        bird.setAge(2);

        bird.eat();
        bird.move();
        if(bird instanceof Bird) {
            ((Bird)bird).setColor("蓝");
            ((Bird)bird).sing();
        }

        Dog dog=new Dog();

        dog.eat();

        dog.move();


        Person p1=new Person("aaa");
        p1.move();

        Person p2=new Baby("bbb");
        p2.move();

        p2.move(new Plain());
        p1.move(new Train());


    }

}
